<script>
function CheckValue(){
	var form = document.frm;
	if(form.ten_sp.value == "Từ khóa"){
		alert("Mời bạn nhập vào từ khóa tìm kiếm");
		form.ten_sp.focus();
		return false;
	}
	return true;
}
function s_a(){
	var form = document.frm;
	/*if(form.ten_sp_adv.value == "Từ khóa"){
		alert("Mời bạn nhập vào từ khóa tìm kiếm");
		form.ten_sp_adv.focus();
		return false;
	}*/
	form.action = "?modul=sanpham&action=search_advance_text";
	form.submit();
	return true;
}
function getSearchAdvance(str,act){
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 
	xmlhttp.onreadystatechange=function()
  	{
		 if (xmlhttp.readyState == 4) {
			// only if "OK"
			if (xmlhttp.status == 200) {						
				document.getElementById('searchAdvanceForm').innerHTML=xmlhttp.responseText;	
				document.getElementById("closeForm").value = 1;
			} else {
				alert("There was a problem while using XMLHTTP:\n" + xmlhttp.statusText);
			}
		}				
	 
 	 }
	 
	xmlhttp.open("GET","../includes/i_timkiem_advance.php?modul="+str+"&action="+act,true);	
	xmlhttp.send();
}
function getSearchAdvanceClose(){
if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 
	xmlhttp.onreadystatechange=function()
  	{
		 if (xmlhttp.readyState == 4) {
			// only if "OK"
			if (xmlhttp.status == 200) {						
				document.getElementById('searchAdvanceForm').innerHTML=xmlhttp.responseText;	
				document.getElementById("closeForm").value = 0;
			} else {
				alert("There was a problem while using XMLHTTP:\n" + xmlhttp.statusText);
			}
		}				
	 
 	 }
	 
	xmlhttp.open("GET","../includes/i_slide_show.php",true);	
	xmlhttp.send();
}
function getSearchAdvanceCloseSP(){
	if (window.XMLHttpRequest)
	  {// code for IE7+, Firefox, Chrome, Opera, Safari
	  xmlhttp=new XMLHttpRequest();
	  }
	else
	  {// code for IE6, IE5
	  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 
	xmlhttp.onreadystatechange=function()
  	{
		 if (xmlhttp.readyState == 4) {
			// only if "OK"
			if (xmlhttp.status == 200) {						
				document.getElementById('searchAdvanceForm').innerHTML=xmlhttp.responseText;	
				document.getElementById("closeForm").value = 0;
			} else {
				alert("There was a problem while using XMLHTTP:\n" + xmlhttp.statusText);
			}
		}				
	 
 	 }
	 
	xmlhttp.open("GET","../includes/i_slide_show_hide.php",true);	
	xmlhttp.send();
}
</script>

<form name="frm" method="post" action="?modul=sanpham&action=SearchText" onsubmit="return CheckValue()" >	
	<table border="0" cellpadding="0" cellspacing="0" style="margin-bottom:3px">
    <tr>
    	<td>
			<input name="ten_sp" type="text"  id="search_text1"
				onfocus="if(value=='Từ khóa') value=''" onblur="if(value=='') value='Từ khóa'"
					value="<? echo $_SESSION['ten_sp']!=''?$_SESSION['ten_sp']:($_POST['ten_sp']!= ''?$_POST['ten_sp']:"Từ khóa");?>" />
		</td>
		<td style="padding-left:5px">
		<select name="loai_sp"  id="search_select">
			<option value="0">Chọn tất cả sản phẩm</option>
			<?
				global $db;
				include_once(DIR_MODEL."md_cat_san_pham.class.php");
				$objCatSanphamTK = new MD_CatSanpham($db);
				$arrayData_CatSanphamTK0 =  array();
				$arrayData_CatSanphamTK =  array();
				$arrayData_CatSanphamTK0 = $objCatSanphamTK->getByWhere("*","hien_thi=1 and parent_id = 0","thu_tu asc");
				$arrayData_CatSanphamTK = $objCatSanphamTK->getByWhere("*","hien_thi=1 and parent_id <> 0","thu_tu asc");
				if(!empty($arrayData_CatSanphamTK0)){
					foreach($arrayData_CatSanphamTK0 as $rowTK0){
						$idTK0 = $rowTK0['id'];
						$nameTK0 = $rowTK0['ten_loai_sp'];
			?>
						<option value="<?=$idTK0?>" style="font-size:12px; font-family:tahoma;"
						  <? if($_SESSION['loai_sp_search'] == $idTK0){?> selected <? }?>	>
						<?=$nameTK0?>
						</option>
			<? 
					}//ket thuc foreach($arrayData_CatSanphamTK0 as $row0)
				}//ket thuc if(!empty($arrayData_CatSanphamTK0))
			?>
		</select>
		</td>
		<td style="padding-left:20px"><input name="Submit" type="submit"  value="Tìm" id="search_button"/></td>
		<td>
		<div id="search_adv"><a  onclick="return getSearchAdvance('<?=CM_getParameter(MODUL)?>','<?=CM_getParameter(ACTION)?>');" style="color:#fff; cursor:pointer; ">Tìm nâng cao</a></div>
        
        </td>
	</tr>
    </table>
</form>